package com.blog.bean.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * @author 任浩
 * @version 1.0
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class NoteVO {

    private Integer id;

    private String title;

    private String content;

    private String type;

    private String titleUrl;

    private String userName;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    private String description;


    //使用构建者设计模式，根据可选参数生成不同的对象
    public static class NoteVOBuilder {
        private Integer id;
        private String title;
        private String content;
        private String type;
        private String titleUrl;
        private String userName;
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime updateTime;
        private String description;

        public NoteVOBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public NoteVOBuilder title(String title) {
            this.title = title;
            return this;
        }

        public NoteVOBuilder content(String content) {
            this.content = content;
            return this;
        }

        public NoteVOBuilder type(String type) {
            this.type  = type;
            return this;
        }

        public NoteVOBuilder titleUrl(String titleUrl) {
            this.titleUrl = titleUrl;
            return this;
        }

        public NoteVOBuilder updateTime(LocalDateTime updateTime) {
            this.updateTime = updateTime;
            return this;
        }

        public NoteVOBuilder userNmae(String userName) {
            this.userName = userName;
            return this;
        }

        public NoteVOBuilder description(String description) {
            this.description = description;
            return this;
        }
        public NoteVO build() {
            return new NoteVO(id, title, content, type, titleUrl,userName, updateTime,description);
        }
    }

}
